layui.use([ 'form','layer'], function () {
    var $ = layui.$,
        form = layui.form,
        layer = layui.layer;

    form.on("select(wey)",function(data){
        if(data.value == 'false'){
            $("#card").removeClass("layui-hide");
            $.ajax({
                type:"get",
                url:"/ecis/binding-card/getCardSet",
                data:{userId:localStorage.getItem("id")},
                dataType:"json",
                success:function (res) {
                    if (res.code == 200){
                        // 添加银行卡集合
                        let option = '<option value="">请选择银行卡</option>\n';
                        for(let item in res.data){
                            option += '<option value="'+res.data[item].id+'">'+res.data[item].id+'</option>';
                        }
                        $("#payerCard").html(option)
                        form.render();
                    }else{
                        let option = '<option value="">请选择银行卡</option>\n';
                        $("#card").html(option)
                        form.render();
                    }
                }
            })
        }else{
            $("#card").addClass("layui-hide");
        }
    })


    form.on("submit(submit)",function (data) {
        data = data.field
        data.userId = localStorage.getItem("id")
        $.ajax({
            type:"post",
            url: "/ecis/trade/transfer",
            data:data,
            dataType: "json",
            success:function (res) {
                if (res.code == 200){
                    layer.msg(res.msg,{icon:1})
                }else{
                    layer.msg(res.msg,{icon:2})
                }
            }
        })
    })

    form.render()

})